package org.dk.service.Impl;

import com.alibaba.dubbo.config.annotation.Service;
import org.dk.mapper.TbAreasMapper;
import org.dk.mapper.TbCitiesMapper;
import org.dk.mapper.TbProvincesMapper;
import org.dk.pojo.*;
import org.dk.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class CityServiceImpl implements CityService {

    @Autowired
    private TbProvincesMapper provincesMapper;
    @Autowired
    private TbCitiesMapper citiesMapper;
    @Autowired
    private TbAreasMapper areasMapper;
    @Override
    public List<TbProvinces> selectProvinces() {
        return provincesMapper.selectByExample(new TbProvincesExample());
    }

    @Override
    public List<TbCities> selectCities() {
        return citiesMapper.selectByExample(new TbCitiesExample());
    }

    @Override
    public List<TbAreas> selectAreas() {
        return areasMapper.selectByExample(new TbAreasExample());
    }

    @Override
    public List<TbCities> selectCitiesById(String id) {
        TbCitiesExample example = new TbCitiesExample();
        TbCitiesExample.Criteria criteria = example.createCriteria();
        criteria.andProvinceidEqualTo(id);
        return citiesMapper.selectByExample(example);
    }

    @Override
    public List<TbAreas> selectAreasById(String id) {
        TbAreasExample example = new TbAreasExample();
        TbAreasExample.Criteria criteria = example.createCriteria();
        criteria.andCityidEqualTo(id);
        return areasMapper.selectByExample(example);
    }
}
